﻿package net.wangit.view.unit.sum;

import net.wangit.Row;
import net.wangit.view.unit.UnitComponent;

public class A1 extends SumItem {

	private String x;
	private String y;

	public A1(UnitComponent uc, int begin, int end, String configs[]) {
		super(uc, begin, end, configs);
		String temp = configs[1].toLowerCase();
		int index1 = temp.indexOf("=");
		int index2 = temp.indexOf("/");
		if (index1 > 0 && index2 > 0) {
			x = temp.substring(index1 + 1, index2).trim();
			y = temp.substring(index2 + 1).trim();
		}
	}

	protected void sum(SumValue sv, Row row) {
		if (x != null && y != null)
			sv.sum(row.get(x), row.get(y));
		else
			sv.sum(row.get(sumName), "1");
	}
}
